var t = require("../../../../@babel/runtime/helpers/interopRequireDefault"), e = require("../../../../@babel/runtime/helpers/defineProperty"), a = t(require("../../../../utils/util.js")), s = getApp(), i = require("../../../../mybehaviors/location/location");

Page({
    behaviors: [ i ],
    data: {
        options: {},
        _root_tag: "",
        TAG_ACTION_BUY: "-2",
        TAG_ACTION_CART: "-1",
        _goodsId: "",
        _optionsId: "",
        _total: 1,
        _cart_ids: [],
        _packagJson: {},
        currentAddId: "",
        currentAddress: {},
        store_id: 0,
        selectedMode: 0,
        selected: 0,
        dispatch: [],
        storeCarts: [],
        store_info: {},
        linkinfo: {
            mobile: "",
            name: ""
        },
        cup_notice: !0,
        create: !0,
        dispatchName: {
            1: "快递",
            2: "上门自提",
            3: "送货上门"
        },
        popupSpecs: !1,
        addressData: [],
        defaultAddress: {},
        realname: "",
        mobile: "",
        address: "",
        order_data: "",
        dispatch_price: 0,
        goods_price: 0,
        price: 0,
        discount_price: 0,
        deduction_price: 0,
        goodsInfo: {},
        popupCouponSpecs: !1,
        checkCouponList: [],
        coupon_size: 0,
        use_coupon_size: 0,
        coupons: [],
        checkDeductionList: [],
        form: {
            username: "",
            mobile: "",
            province: "",
            city: "",
            district: "",
            street: "",
            address: "",
            isDefault: !1
        },
        addressName: "",
        districtVal: "",
        popAddAddress: !1,
        strShow: !1,
        openDateLw: !1,
        provinceData: [],
        cityData: [],
        districtData: [],
        pickerValue: [ 0, 0, 0 ],
        selectAddressData: [],
        streetShow: !1,
        myRealname: "",
        myIdcard: "",
        showMyinfo: !1,
        currentIndex: "999",
        isOpenRight: !1,
        isRightChoose: !1,
        isRent: !1,
        rentTime: [],
        rentFree: "",
        rent_deposit_free: 0,
        agreeCon: {},
        rent_free: 0,
        rentShow: !1,
        tenancy: "",
        note: {},
        isTaxGoods: !1,
        member_name: "",
        member_card: "",
        explain_title: "",
        explain_content: "",
        agreement: !1,
        agreementShow: !1,
        submit_active: !0,
        AgreementPay: "",
        agreementPay: !1,
        agreementPayShow: !1,
        show_address: !0,
        isShowInvoice: !0,
        invoice_status: !0,
        papery_status: "",
        electron_status: "",
        person_status: !0,
        unit_status: !1,
        iscur: !0,
        iscur_b: !1,
        iscur_c: !0,
        iscur_d: !1,
        invoice_list: {
            call: "",
            company_number: ""
        },
        total_items: [],
        discount_amount_items: [],
        service: {},
        isCash: "",
        goodsId: "",
        show1: !1,
        pdOrderType: [ {
            name: "自用",
            code: "1"
        } ],
        POChooseType: "0",
        isOpenTeam: !1,
        isJoinTeam: !1,
        opren: !0,
        is_open_package_deliver: !1,
        selfCarryType: [ {
            name: "快递",
            dispatch_type_id: 1
        }, {
            name: "自提",
            dispatch_type_id: 8
        } ],
        selfCarrySelected: 0,
        point: {
            lat: "",
            lng: ""
        },
        city: "",
        defaultSelfCarry: {},
        package_deliver_id: "1"
    },
    onLoad: function(t) {
        var e = this;
        this.setData({
            options: t
        });
        var a = !s._isTextEmpty(t.level_id);
        this.setData({
            isOpenTeam: a
        });
        var i = !s._isTextEmpty(t.team_id);
        if (this.setData({
            isJoinTeam: i
        }), t.tag && this.setData({
            _root_tag: t.tag
        }), "1" == wx.getStorageSync("yz_basic_info").globalParameter.is_open_package_deliver) {
            if (console.log("开启自提点（杨朗）"), t.changeSelfCarry) {
                var o = JSON.parse(t.changeSelfCarry);
                this.setData({
                    defaultSelfCarry: o,
                    selfCarrySelected: 1,
                    package_deliver_id: 8
                });
            } else this._getLocation(function() {
                e.getList();
            });
            this.setData({
                is_open_package_deliver: !0
            });
        }
        this.data._root_tag == this.data.TAG_ACTION_BUY || "auction" == this.data._root_tag ? (this.setData({
            _goodsId: t.goodsId,
            _optionsId: t.optionsId,
            _total: t.total
        }), this._getDataActionBuy()) : this.data._root_tag == this.data.TAG_ACTION_CART ? (this.setData({
            _cart_ids: t.cart_ids ? JSON.parse(t.cart_ids) : []
        }), this._getDataActionCart()) : "store" == this.data._root_tag ? (this.setData({
            store_id: t.store_id,
            isCash: t.isCash
        }), 1 === this.data.isCash ? this.getCashGood() : this._initStore()) : "rentCartBuy" == this.data._root_tag ? (this.setData({
            currentIndex: "999",
            _cart_ids: t.cart_ids ? JSON.parse(t.cart_ids) : [],
            isRent: !0
        }), this._getRentDataActionCart([], []), this._getRentTimeList(), this._judgeIsRight()) : "rentBuy" == this.data._root_tag ? (this.setData({
            currentIndex: "999",
            isRent: !0,
            _goodsId: t.goodsId,
            _optionsId: t.optionsId,
            _total: t.total
        }), this._getRentDataActionCart([], []), this._getRentTimeList(), this._judgeIsRight()) : "packagBuy" == this.data._root_tag ? this.setData({
            _packagJson: t.packagJson,
            _cart_ids: t.cart_ids
        }) : "POrder" == this.data._root_tag ? (this.checktag(), this.setData({
            _goodsId: t.goodsId,
            _optionsId: t.optionsId,
            _total: t.total
        }), this._getDataActionBuy()) : "fromExchange" == this.data._root_tag && (this.setData({
            _goodsId: t.goodsId
        }), this.getExchangeData()), this.getParams(), this._initAddressInfo();
    },
    _checkTaxGoods: function(t) {
        t.status ? (this.setData({
            showMyinfo: t.status
        }), this.data.isTaxGoods = !0) : (this.data.isTaxGoods = !1, this.setData({
            showMyinfo: !1
        }));
    },
    swichTabTItem: function(t) {
        console.log(t.detail.index), this.setData({
            POChooseType: t.detail.index
        });
    },
    _getMemberInfo: function(t) {
        this.setData({
            member_name: t.realname,
            member_card: t.idcard,
            myRealname: t.realname,
            myIdcard: t.idcard
        });
    },
    _getExplain: function(t) {
        this.data.explain_title = t.explain_title, this.data.explain_content = t.explain_content;
    },
    alertMyInfo: function() {
        wx.navigateTo({
            url: "/packageB/member/address/myinfo/myinfo?tag=delta"
        });
    },
    gotochangeSelfCarry: function() {
        wx.navigateTo({
            url: "/packageC/selfCarry/selfCarry_info/selfCarry_info?tag=" + this.data.options.tag + "&goodsId=" + this.data.options.goodsId + "&optionsId=" + this.data.options.optionsId + "&total=" + this.data.options.total + "&goods=" + JSON.stringify(this._assembleGoods())
        });
    },
    checktag: function() {
        console.log("檢查tag");
        var t = this, e = s.getNetAddresss("plugin.pending-order.frontend.wholesale-area.index");
        s._getNetWork({
            url: e,
            success: function(e) {
                var s = e.data;
                1 == s.result && (console.log(s), t.setData({
                    activity: s.data.activity,
                    activity_time: s.data.activity.end_time
                }), Date.parse(a.default.formatTime(new Date())) > Date.parse(t.data.activity_time.replace(/-/g, "/")) ? t.setData({
                    isfot: !1
                }) : t.setData({
                    isfot: !0
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    setDispatch: function(t) {
        var e = t.detail.title;
        this.data.dispatchName[1] === e ? this.setData({
            selected: 1
        }) : this.data.dispatchName[2] === e ? this.setData({
            selected: 2
        }) : this.data.dispatchName[3] === e && this.setData({
            selected: 3
        }), this._getDataActionStoreCart();
    },
    _initStore: function() {
        var t = this;
        t.setData({
            recipient_name: "",
            recipient_mobile: ""
        });
        var e = s.getNetAddresss("plugin.store-cashier.frontend.store.get-store-info.get-info-by-store-id");
        e += "&store_id=" + this.data.store_id, s._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                1 == a.result ? (t.setData({
                    store_info: a.data,
                    dispatch: a.data.dispatch_type,
                    selected: a.data.dispatch_type[0],
                    recipient_name: a.data.store_carry.name,
                    recipient_mobile: a.data.store_carry.number
                }), t._getDataActionStoreCart()) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _getDataActionStoreCart: function() {
        var t = this, e = s.getNetAddresss("plugin.store-cashier.frontend.shoppingCart.member-cart.index");
        e += "&store_id=" + this.data.store_id, s._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                1 == a.result ? (t.setData({
                    cup_notice: !0,
                    storeCarts: []
                }), a.data.forEach(function(e) {
                    var a = t.data.storeCarts;
                    a.push(e.id), t.setData({
                        storeCarts: a
                    });
                }), t._getStoreCartBuy(t.data.storeCarts)) : (t.setData({
                    cup_notice: !0
                }), wx.showToast({
                    icon: "none",
                    title: "无商品",
                    duration: 1500
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _getStoreInfo: function() {
        var t = this, e = s.getNetAddresss("plugin.store-cashier.frontend.store.get-store-info.get-info-by-store-id");
        e += "&store_id=" + this.data.store_id, s._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                1 == a.result ? (t.setData({
                    store_info: a.data,
                    dispatch: a.data.dispatch_type
                }), t.data.dispatch.length > 0 && (t.data.selected || t.setData({
                    selected: t.data.dispatch[0]
                }))) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    showAddress: function() {
        this._getAddress();
    },
    _getAddress: function() {
        this.addressData = [];
        var t = this, e = s.getNetAddresss("member.member-address.index");
        s._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                if (1 == a.result) {
                    var s = a.data;
                    s = a.data.filter(function(t) {
                        return 1 === t.isdefault;
                    }), t.setData({
                        popupSpecs: !0,
                        addressData: a.data,
                        defaultAddress: s
                    });
                } else wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _setAddressViewData: function(t) {
        null != t && "" != t && t != [] && (this.data.currentAddId = t.id, this.data.currentAddress = t, 
        this.setData({
            realname: s._isTextEmpty(t.username) ? "" : t.username,
            mobile: s._isTextEmpty(t.mobile) ? "" : t.mobile,
            address: s._isTextEmpty(t.province) ? "" : t.province + " " + t.city + " " + t.district + " " + (s._isTextEmpty(t.street) ? "" : t.street + " ") + t.address
        }));
    },
    _getStoreCartBuy: function(t) {
        var e = this, a = s.getNetAddresss("plugin.store-cashier.frontend.store.cart-buy");
        a += "&cart_ids=" + t, a += "&store_id=" + e.data.store_id, a += "&dispatch_type_id=" + e.data.selected, 
        a += "&member_coupon_ids=" + this._assembleCoupons(), a += "&orders=" + JSON.stringify(this._assembleDeduction()), 
        a += "&address=" + JSON.stringify(this.data.currentAddress), s._getNetWork({
            url: a,
            success: function(t) {
                var a = t.data;
                1 == a.result ? (e.setData({
                    goodsInfo: a.data
                }), e._setViewData(a.data), e._setAddressViewData(a.data.dispatch.default_member_address), 
                e._initCoupon(a.data.discount.member_coupons), e.data.is_open_package_deliver && e.setData({
                    selfCarryType: a.data.dispatch.delivery_method
                })) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _assembleCoupons: function() {
        for (var t = [], e = 0; e < this.data.checkCouponList.length; e++) t.push(this.data.checkCouponList[e].id);
        return t;
    },
    _assembleDeduction: function() {
        for (var t = [], e = 0; e < this.data.checkDeductionList.length; e++) t.push(this.data.checkDeductionList[e]);
        return t;
    },
    _setViewData: function(t) {
        console.log(t.fee_items, "服务费"), console.log(t, "右束支"), this.setData({
            order_data: t.orders,
            show_address: t.orders[0].need_address,
            price: t.total_price,
            total_items: t.amount_items,
            discount_amount_items: t.discount_amount_items,
            service: t.orders[0].order_fees
        }), console.log(this.data.service, "服务费65655656"), "store" == this.data._root_tag && this.data.price < 0 && wx.showToast({
            icon: "none",
            title: "下单错误",
            duration: 1500
        });
    },
    _initCoupon: function(t) {
        null != t && "" != t && null != t && this.setData({
            coupon_size: t.length
        });
        var e = [];
        t.forEach(function(t, a) {
            1 == t.checked && e.push(t);
        }), this.setData({
            coupons: t,
            use_coupon_size: e.length
        });
    },
    infonamebtn: function(t) {
        var e = t.detail;
        this.setData({
            "linkinfo.name": e
        });
    },
    infonameclear: function() {
        this.setData({
            "linkinfo.name": ""
        });
    },
    infomobileclear: function() {
        this.setData({
            "linkinfo.mobile": ""
        });
    },
    infomobilebtn: function(t) {
        var e = t.detail;
        this.setData({
            "linkinfo.mobile": e
        });
    },
    addresclosebtn: function() {
        this.setData({
            popupSpecs: !1
        });
    },
    selectAddress: function(t) {
        var e = t.currentTarget.dataset.addr;
        this._setAddressViewData(e), this._requestByAddress(), this.setData({
            popupSpecs: !1
        });
    },
    _requestByAddress: function() {
        this.data._root_tag == this.data.TAG_ACTION_BUY || "auction" == this.data.root_tag ? (this.setData({
            order_data: ""
        }), this._getDataActionBuy()) : "fromExchange" == this.data._root_tag ? (this.setData({
            order_data: ""
        }), this.getExchangeData(0)) : this.data._root_tag == this.data.TAG_ACTION_CART ? (this.setData({
            order_data: ""
        }), this._getDataActionCart()) : "store" == this.data._root_tag ? this._getDataActionStoreCart() : "rentCartBuy" == this.data_root_tag || "rentBuy" == this.data._root_tag ? this._rentGoodBuy() : "packagBuy" == this.data._root_tag && this.setData({
            order_data: ""
        });
    },
    editAddress: function() {
        this.setData({
            "form.address_id": this.data.defaultAddress[0].id,
            "form.username": this.data.defaultAddress[0].username,
            "form.mobile": this.data.defaultAddress[0].mobile,
            "form.province": this.data.defaultAddress[0].province,
            "form.city": this.data.defaultAddress[0].city,
            "form.district": this.data.defaultAddress[0].district,
            "form.address": this.data.defaultAddress[0].address,
            "form.street": this.data.defaultAddress[0].street,
            "form.isDefault": 0 !== this.data.defaultAddress[0].isDefault
        }), this.setData({
            popupSpecs: !1,
            create: !1,
            popAddAddress: !0
        }), this._getStreet(this.data.defaultAddress[0].district_id), this.setData({
            addressName: this.data.form.province + " " + this.data.form.city + " " + this.data.form.district
        });
    },
    popAddressClose: function() {
        this.setData({
            popAddAddress: !1
        });
    },
    usernameinp: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.username": e
        });
    },
    mobileinp: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.mobile": e
        });
    },
    isDefaultChange: function(t) {
        var e = t.detail;
        this.setData({
            "form.isDefault": e
        });
    },
    addressinp: function(t) {
        var e = t.detail.value;
        console.log(e), this.setData({
            "form.address": e
        });
    },
    _closeDateLw: function() {
        this.setData({
            openDateLw: !1
        });
    },
    _initAddressInfo: function() {
        var t = this;
        wx.getStorage({
            key: "provinceData",
            success: function(e) {
                console.log("地址信息准备就绪"), t._getProvinceData();
            },
            fail: function(e) {
                console.log("省fail"), s._getNetWork({
                    url: s.getNetAddresss("member.member-address.address"),
                    success: function(e) {
                        var a = e.data, s = a.data.province, i = a.data.city, o = a.data.district;
                        wx.setStorage({
                            key: "provinceData",
                            data: s
                        }), wx.setStorage({
                            key: "cityData",
                            data: i
                        }), wx.setStorage({
                            key: "districtData",
                            data: o
                        }), t._initAddressInfo();
                    },
                    fail: function(t) {},
                    state: !0
                });
            }
        });
    },
    _getProvinceData: function() {
        var t = this;
        wx.getStorage({
            key: "provinceData",
            success: function(e) {
                console.log("省读取成功", e.data), t.setData({
                    provinceData: e.data
                }), t.setData({
                    "selectAddressData[0].name": e.data[t.data.pickerValue[0]].areaname,
                    "selectAddressData[0].id": e.data[t.data.pickerValue[0]].id,
                    "selectAddressData[0].index": t.data.pickerValue[0]
                }), t._getCityData();
            }
        });
    },
    _getCityData: function() {
        var t = this.data.selectAddressData[0];
        console.log("城市", "_data", t);
        var e = this;
        wx.getStorage({
            key: "cityData",
            success: function(a) {
                console.log("城市读取成功", a);
                for (var s = [], i = 0; i < a.data.length; i++) a.data[i].parentid == t.id && s.push(a.data[i]);
                console.log("城市数据筛选", s), e.setData({
                    cityData: s
                }), e.setData({
                    "selectAddressData[1].name": s[e.data.pickerValue[1]].areaname,
                    "selectAddressData[1].id": s[e.data.pickerValue[1]].id,
                    "selectAddressData[1].index": e.data.pickerValue[1]
                }), e._getDistrictData();
            }
        });
    },
    _getDistrictData: function() {
        var t = this.data.selectAddressData[1];
        console.log("地区", "_data", t), console.log(t);
        var e = this;
        wx.getStorage({
            key: "districtData",
            success: function(a) {
                console.log("地区读取成功");
                for (var s = [], i = 0; i < a.data.length; i++) a.data[i].parentid == t.id && s.push(a.data[i]);
                console.log("地区数据筛选", s), e.setData({
                    districtData: s
                }), console.log("districtData", s), e.setData({
                    "selectAddressData[2].name": s[e.data.pickerValue[2]].areaname,
                    "selectAddressData[2].id": s[e.data.pickerValue[2]].id,
                    "selectAddressData[2].index": e.data.pickerValue[2]
                }), console.log("over", e.data.selectAddressData);
            }
        });
    },
    openDateLwtbtn: function() {
        this.setData({
            openDateLw: !0
        });
    },
    bindChange: function(t) {
        var e = t.detail.value;
        this.data.pickerValue[0] != e[0] && (e[1] = 0, e[2] = 0), this.data.pickerValue[1] != e[1] && (e[2] = 0), 
        this.setData({
            "pickerValue[0]": e[0],
            "pickerValue[1]": e[1],
            "pickerValue[2]": e[2]
        }), this._initAddressInfo();
    },
    _okAddress: function() {
        var t = this.data.selectAddressData;
        this.setData({
            "form.street": "",
            districtVal: "",
            addressName: t[0].name + " " + t[1].name + " " + t[2].name,
            "form.province": t[0].name,
            "form.city": t[1].name,
            "form.district": t[2].name
        }), this._getStreet(t[2].id), this._closeDateLw();
    },
    _getStreet: function(t) {
        var e = this, a = s.getNetAddresss("member.memberAddress.street");
        a += "&district_id=" + t, s._getNetWork({
            url: a,
            success: function(t) {
                var a = t.data;
                1 != a.result || s._isTextEmpty(a.data) ? e.setData({
                    strShow: !1
                }) : !s._isTextEmpty(a.data) && a.data.length > 0 ? e.setData({
                    districtVal: a.data,
                    strShow: !0
                }) : e.setData({
                    strShow: !1
                });
            },
            fail: function(t) {
                e.setData({
                    strShow: !1
                }), console.log(t);
            }
        });
    },
    streetChoose: function() {
        s._isTextEmpty(this.data.addressName) ? wx.showToast({
            icon: "none",
            title: "请先选择所在地区",
            duration: 1500
        }) : this.setData({
            streetShow: !0,
            opren: !1
        });
    },
    streetClose: function() {
        this.setData({
            streetShow: !1,
            opren: !0
        });
    },
    streetConfirm: function(t) {
        var e = t.target.dataset.strname;
        this.setData({
            "form.street": e,
            streetShow: !1,
            opren: !0
        });
    },
    appendAddress: function(t) {
        var e = this, a = t.currentTarget.dataset.apptype;
        if (s._isTextEmpty(this.data.form.username)) wx.showToast({
            icon: "none",
            title: "请输入收货人姓名",
            duration: 1500
        }); else if (s._isTextEmpty(this.data.form.mobile)) wx.showToast({
            icon: "none",
            title: "请输入联系电话",
            duration: 1500
        }); else if (/^[0-9]{1,}$/.test(this.data.form.mobile)) if (s._isTextEmpty(this.data.addressName)) wx.showToast({
            icon: "none",
            title: "请选择所在区域",
            duration: 1500
        }); else if (this.data.strShow && s._isTextEmpty(this.data.form.street)) wx.showToast({
            icon: "none",
            title: "请选择所在街道",
            duration: 1500
        }); else if (s._isTextEmpty(this.data.form.address)) wx.showToast({
            icon: "none",
            title: "请输入详细地址",
            duration: 1500
        }); else {
            var i = {};
            i = this.data.strShow ? {
                username: this.data.form.username,
                mobile: this.data.form.mobile,
                province: this.data.form.province,
                city: this.data.form.city,
                district: this.data.form.district,
                street: this.data.form.street,
                address: this.data.form.address,
                isdefault: this.data.form.isDefault ? 1 : 0,
                address_id: this.data.form.address_id
            } : {
                username: this.data.form.username,
                mobile: this.data.form.mobile,
                province: this.data.form.province,
                city: this.data.form.city,
                district: this.data.form.district,
                address: this.data.form.address,
                isdefault: this.data.form.isDefault ? 1 : 0,
                address_id: this.data.form.address_id
            };
            var o = "";
            o = "update" === a ? s.getNetAddresss("member.member-address.update") : s.getNetAddresss("member.member-address.store"), 
            s._postNetWork({
                url: o,
                showToastIn: !1,
                data: i,
                success: function(t) {
                    var a = t.data;
                    1 == a.result ? (wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    }), e.popAddressClose(), e._setAddressViewData(a.data), e._requestByAddress(), e.setData({
                        "form.username": "",
                        "form.mobile": "",
                        "form.province": "",
                        "form.city": "",
                        "form.district": "",
                        "form.street": "",
                        "form.address": "",
                        "form.isDefault": !1,
                        addressName: ""
                    })) : wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {}
            });
        } else wx.showToast({
            icon: "none",
            title: "请输入联系电话",
            duration: 1500
        });
    },
    addAddress: function() {
        this.setData({
            popupSpecs: !1
        }), this.showAddAddress();
    },
    showAddAddress: function() {
        this.setData({
            "form.username": "",
            "form.mobile": "",
            "form.province": "",
            "form.city": "",
            "form.district": "",
            "form.street": "",
            "form.address": "",
            "form.isDefault": !1,
            addressName: "",
            popAddAddress: !0,
            create: !0
        });
    },
    _getRentDataActionCart: function(t, e) {
        if ("rentCartBuy" == this.data._root_tag) {
            var a = this, i = s.getNetAddresss("plugin.lease-toy.api.order.cart-buy");
            i += "&lease_rights=" + t, i += "&lease_term=" + e, i += "&cart_ids=" + this.data._cart_ids, 
            i += "&member_coupon_ids=" + this._assembleCoupons(), i += "&orders=" + JSON.stringify(this._assembleDeduction()), 
            i += "&address=" + JSON.stringify(this.data.currentAddress), i += "&dispatch_type_id=1", 
            i += "&mark=" + (this.data.options.mark ? this.data.options.mark : 0), s._getNetWork({
                url: i,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? (a.setData({
                        goodsInfo: e.data,
                        cup_notice: !0
                    }), a._setViewData(e.data), a._setAddressViewData(e.data.dispatch.default_member_address), 
                    a._initCoupon(e.data.discount.member_coupons), a.data.is_open_package_deliver && a.setData({
                        selfCarryType: e.data.dispatch.delivery_method
                    })) : (a.setData({
                        cup_notice: !0
                    }), wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else if ("rentBuy" == this.data._root_tag) {
            var o = this, d = s.getNetAddresss("plugin.lease-toy.api.order.goods-buy");
            d += "&lease_rights=" + t, d += "&lease_term=" + e, d += "&goods_id=" + this.data._goodsId, 
            d += "&total=" + this.data._total, d += "&option_id=" + this.data._optionsId, d += "&member_coupon_ids=" + this._assembleCoupons(), 
            d += "&orders=" + JSON.stringify(this._assembleDeduction()), d += "&address=" + JSON.stringify(this.data.currentAddress), 
            d += "&dispatch_type_id=1", d += "&mark=" + (this.data.options.mark ? this.data.options.mark : 0), 
            s._getNetWork({
                url: d,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? (o.setData({
                        goodsInfo: e.data,
                        cup_notice: !0
                    }), o._setViewData(e.data), o._setAddressViewData(e.data.dispatch.default_member_address), 
                    o._initCoupon(e.data.discount.member_coupons), o.data.is_open_package_deliver && o.setData({
                        selfCarryType: e.data.dispatch.delivery_method
                    })) : wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    _getRentTimeList: function() {
        var t = this, e = s.getNetAddresss("plugin.lease-toy.api.lease-term.index");
        s._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                1 == a.result && t.setData({
                    rentTime: a.data.list,
                    rentFree: a.data.level.rent_free,
                    agreeCon: a.data.lease_toy_set,
                    rent_deposit_free: a.data.level.deposit_free,
                    rent_free: a.data.level.rent_free
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _judgeIsRight: function() {
        this.data.isOpenRight ? this.setData({
            isRightChoose: !1
        }) : this.setData({
            isRightChoose: !0
        });
    },
    noteHandle: function(t) {
        var a = t.target.dataset.preid, i = t.target.dataset.item, o = t.detail.value;
        if (this.setData(e({}, "note." + a, o)), i.order_deductions[0]) this._screenDiscount(i, i.order_deductions[0]); else {
            var d = {}, r = [];
            if (this.data.checkDeductionList.length > 0) {
                for (var n = 0; n < this.data.checkDeductionList.length; n++) if (this.data.checkDeductionList[n].pre_id == i.pre_id) {
                    r = s._isTextEmpty(this.data.checkDeductionList[n].deduction_ids) ? [] : this.data.checkDeductionList[n].deduction_ids;
                    var c = this.data.checkDeductionList;
                    c.splice(n, 1), this.setData({
                        checkDeductionList: c
                    });
                    break;
                }
                if (r.length > 0) {
                    for (var h = 0; h < r.length; h++) r[h] == value.code && r.splice(h, 1);
                    d.deduction_ids = r, d.pre_id = i.pre_id, d.note = this.data.note[i.pre_id];
                    var _ = this.data.checkDeductionList;
                    _.push(d), this.setData({
                        checkDeductionList: _
                    });
                } else {
                    d.deduction_ids = r, d.pre_id = i.pre_id, d.note = this.data.note[i.pre_id];
                    var u = this.data.checkDeductionList;
                    u.push(d), this.setData({
                        checkDeductionList: u
                    });
                }
            } else if (r.length > 0) {
                for (var l = 0; l < r.length; l++) r[l] == value.code && r.splice(l, 1);
                d.deduction_ids = r, d.pre_id = i.pre_id, d.note = this.data.note[i.pre_id];
                var p = this.data.checkDeductionList;
                p.push(d), this.setData({
                    checkDeductionList: p
                });
            } else {
                d.deduction_ids = r, d.pre_id = i.pre_id, d.note = this.data.note[i.pre_id];
                var g = this.data.checkDeductionList;
                g.push(d), this.setData({
                    checkDeductionList: g
                });
            }
        }
    },
    _screenDiscount: function(t, e) {
        var a = {}, i = [];
        if (e.checked) if (this.data.checkDeductionList.length > 0) {
            for (var o = 0; o < this.data.checkDeductionList.length; o++) if (this.data.checkDeductionList[o].pre_id == t.pre_id) {
                i = s._isTextEmpty(this.data.checkDeductionList[o].deduction_ids) ? [] : this.data.checkDeductionList[o].deduction_ids;
                var d = this.data.checkDeductionList;
                d.splice(o, 1), this.setData({
                    checkDeductionList: d
                });
                break;
            }
            if (i.length > 0) {
                for (var r = 0; r < i.length; r++) i[r] == e.code && i.splice(r, 1);
                i.push(e.code), a.deduction_ids = i, a.pre_id = t.pre_id, a.note = this.data.note[t.pre_id];
                var n = this.data.checkDeductionList;
                n.push(a), this.setData({
                    checkDeductionList: n
                });
            } else {
                i.push(e.code), a.deduction_ids = i, a.pre_id = t.pre_id, a.note = this.data.note[t.pre_id];
                var c = this.data.checkDeductionList;
                c.push(a), this.setData({
                    checkDeductionList: c
                });
            }
        } else if (i.length > 0) {
            for (var h = 0; h < i.length; h++) i[h] == e.code && i.splice(h, 1);
            i.push(e.code), a.deduction_ids = i, a.pre_id = t.pre_id, a.note = this.data.note[t.pre_id];
            var _ = this.data.checkDeductionList;
            _.push(a), this.setData({
                checkDeductionList: _
            });
        } else {
            i.push(e.code), a.deduction_ids = i, a.pre_id = t.pre_id, a.note = this.data.note[t.pre_id];
            var u = this.data.checkDeductionList;
            u.push(a), this.setData({
                checkDeductionList: u
            });
        } else if (this.data.checkDeductionList.length > 0) {
            for (var l = 0; l < this.data.checkDeductionList.length; l++) if (this.data.checkDeductionList[l].pre_id == t.pre_id) {
                i = s._isTextEmpty(this.data.checkDeductionList[l].deduction_ids) ? [] : this.data.checkDeductionList[l].deduction_ids;
                var p = this.data.checkDeductionList;
                p.splice(l, 1), this.setData({
                    checkDeductionList: p
                });
                break;
            }
            if (i.length > 0) {
                for (var g = 0; g < i.length; g++) i[g] == e.code && i.splice(g, 1);
                a.deduction_ids = i, a.pre_id = t.pre_id, a.note = this.data.note[t.pre_id];
                var f = this.data.checkDeductionList;
                f.push(a), this.setData({
                    checkDeductionList: f
                });
            } else {
                a.deduction_ids = i, a.pre_id = t.pre_id, a.note = this.data.note[t.pre_id];
                var m = this.data.checkDeductionList;
                m.push(a), this.setData({
                    checkDeductionList: m
                });
            }
        } else if (i.length > 0) {
            for (var D = 0; D < i.length; D++) i[D] == e.code && i.splice(D, 1);
            a.deduction_ids = i, a.pre_id = t.pre_id, a.note = this.data.note[t.pre_id];
            var y = this.data.checkDeductionList;
            y.push(a), this.setData({
                checkDeductionList: y
            });
        } else {
            a.deduction_ids = i, a.pre_id = t.pre_id, a.note = this.data.note[t.pre_id];
            var v = this.data.checkDeductionList;
            v.push(a), this.setData({
                checkDeductionList: v
            });
        }
    },
    rentSelect: function(t) {
        var e = t.detail;
        if (this.setData({
            isOpenRight: e
        }), this._clearStorage(), this._judgeIsRight(), this.data.isOpenRight) {
            var a = [];
            this.data.order_data.forEach(function(t) {
                t.order.order_goods.forEach(function(t) {
                    console.log(t);
                    var e = {
                        goods_id: t.goods_id,
                        total: t.total
                    };
                    a.push(e);
                });
            }), wx.setStorage({
                key: "rentTimeRight",
                data: JSON.stringify(a)
            }), this._getRentDataActionCart(JSON.stringify(a), []);
        } else {
            if (this.data.isOpenRight) return;
            this.setData({
                currentIndex: "999"
            }), this._getRentDataActionCart([], []);
        }
    },
    _clearStorage: function() {
        wx.removeStorage({
            key: "rentTimeSelf"
        }), wx.removeStorage({
            key: "rentTimeChoose"
        }), wx.removeStorage({
            key: "rentTimeRight"
        });
    },
    discountHandle: function(t) {
        var a = t.detail, s = t.currentTarget.dataset.dindex, i = t.currentTarget.dataset.orindex;
        "[object Object]" == Object.prototype.toString.call(this.data.order_data[i].order_deductions) ? this.setData(e({}, "order_data[" + i + "].order_deductions." + s + ".checked", a)) : "[object Array]" == Object.prototype.toString.call(this.data.order_data[i].order_deductions) && this.setData(e({}, "order_data[" + i + "].order_deductions[" + s + "]checked", a)), 
        this._screenDiscount(this.data.order_data[i], this.data.order_data[i].order_deductions[s]), 
        this.data._root_tag == this.data.TAG_ACTION_BUY || "auction" == this.data._root_tag ? this._getDataActionBuy() : this.data._root_tag == this.data.TAG_ACTION_CART ? this._getDataActionCart() : "fromExchange" == this.data._root_tag ? this.getExchangeData(0) : "store" == this.data._root_tag ? this._getDataActionStoreCart() : "rentCartBuy" == this.data._root_tag || "rentBuy" == this.data._root_tag ? this._rentGoodBuy() : this.data._root_tag;
    },
    _rentGoodBuy: function() {
        if (this.data.isOpenRight) {
            var t = "";
            try {
                var e = wx.getStorageSync("rentTimeRight");
                e && (t = e);
            } catch (t) {}
            this._getRentDataActionCart(t, []);
        } else if ("999" == this.data.currentIndex) {
            var a = "";
            try {
                var i = wx.getStorageSync("rentTimeSelf");
                i && (a = i);
            } catch (t) {}
            s._isTextEmpty(a) ? this._getRentDataActionCart([], []) : this.getRentDataActionCart([], a);
        } else {
            var o = "";
            try {
                var d = wx.getStorageSync("rentTimeChoose");
                d && (o = d);
            } catch (t) {}
            s._isTextEmpty(o) || this._getRentDataActionCart([], o);
        }
    },
    rentSelfChoose: function() {
        this._clearStorage(), this.setData({
            currentIndex: "999"
        }), this.setData({
            rentShow: !0
        });
    },
    rentShowClose: function(t) {
        var e = this;
        if ("confirm" === t.detail) {
            if (s._isTextEmpty(this.data.tenancy)) return void wx.showToast({
                icon: "none",
                title: "租期不能为空",
                duration: 1e3
            });
            var a = {
                days: this.data.tenancy,
                lease_term_id: 0
            };
            wx.setStorage({
                key: "rentTimeSelf",
                data: JSON.stringify(a)
            }), this._getRentDataActionCart([], JSON.stringify(a)), setTimeout(function() {
                e.setData({
                    rentShow: !1
                });
            }, 1e3);
        } else this.setData({
            rentShow: !1
        }), console.log("取消自定义租期！！！");
    },
    rentShowinp: function(t) {
        var e = t.detail;
        this.setData({
            tenancy: e
        });
    },
    rentclear: function() {
        this.setData({
            tenancy: ""
        });
    },
    rentTimeChoose: function(t) {
        var e = t.currentTarget.dataset.item, a = t.currentTarget.dataset.index;
        if (this.data.currentIndex == a) this.setData({
            currentIndex: "999"
        }), this._clearStorage(), this._getRentDataActionCart([], []); else {
            this._clearStorage(), this.setData({
                currentIndex: a
            });
            var s = {
                days: 0,
                lease_term_id: e.id
            };
            wx.setStorage({
                key: "rentTimeChoose",
                data: JSON.stringify(s)
            }), this._getRentDataActionCart([], JSON.stringify(s));
        }
    },
    _getDataActionCart: function() {
        var t = this, e = s.getNetAddresss("order.cart-buy");
        e += "&cart_ids=" + this.data._cart_ids, e += "&member_coupon_ids=" + this._assembleCoupons(), 
        e += "&orders=" + JSON.stringify(this._assembleDeduction()), e += "&address=" + JSON.stringify(this.data.currentAddress), 
        e += "&dispatch_type_id=1", s._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                1 == a.result ? (t.setData({
                    goodsInfo: a.data,
                    cup_notice: !0
                }), t._setViewData(a.data), t._setAddressViewData(a.data.dispatch.default_member_address), 
                t._initCoupon(a.data.discount.member_coupons), t.data.is_open_package_deliver && t.setData({
                    selfCarryType: a.data.dispatch.delivery_method
                })) : (t.setData({
                    cup_notice: !0
                }), wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    showCoupon: function() {
        0 != this.data.coupon_size ? this.setData({
            popupCouponSpecs: !0
        }) : wx.showToast({
            icon: "none",
            title: "暂无优惠券使用",
            duration: 1500
        });
    },
    selectCoupon: function(t) {
        var a = t.detail, s = t.currentTarget.dataset.index, i = t.currentTarget.dataset.item;
        this.setData(e({}, "coupons[" + s + "].checked", a)), this._screenCoupon(a, i), 
        this._setCouponView(), this.data._root_tag == this.data.TAG_ACTION_BUY || "auction" == this.data._root_tag ? this._getDataActionBuy() : this.data._root_tag == this.data.TAG_ACTION_CART ? this._getDataActionCart() : "fromExchange" == this.data._root_tag ? this.getExchangeData(0) : "store" == this.data._root_tag ? this._getDataActionStoreCart() : "rentCartBuy" == this.data._root_tag || "rentBuy" == this.data._root_tag ? this._rentGoodBuy() : this.data._root_tag;
    },
    _screenCoupon: function(t, e) {
        var a = e;
        if (t) if (this.setData({
            cup_notice: !1
        }), this.data.checkCouponList.length > 0) {
            for (var s = 0; s < this.data.checkCouponList.length; s++) if (this.data.checkCouponList[s].id == a.id) {
                var i = this.data.checkCouponList;
                i.splice(s, 1), this.setData({
                    checkCouponList: i
                });
            }
            var o = this.data.checkCouponList;
            o.push(a), this.setData({
                checkCouponList: o
            });
        } else {
            var d = this.data.checkCouponList;
            d.push(a), this.setData({
                checkCouponList: d
            });
        } else if (this.setData({
            cup_notice: !0
        }), this.data.checkCouponList.length > 0) for (var r = 0; r < this.data.checkCouponList.length; r++) if (this.data.checkCouponList[r].id == a.id) {
            var n = this.data.checkCouponList;
            n.splice(r, 1), this.setData({
                checkCouponList: n
            });
        }
    },
    _setCouponView: function() {
        this.setData({
            use_coupon_size: this.data.checkCouponList.length
        });
    },
    couponclose: function() {
        this.setData({
            popupCouponSpecs: !1
        });
    },
    agreementbtn: function(t) {
        var e = t.detail;
        this.setData({
            agreement: e
        });
    },
    showAgreement: function() {
        this.setData({
            agreementShow: !0
        });
    },
    agreementClose: function() {
        this.setData({
            agreementShow: !1
        });
    },
    _getDataActionBuy: function() {
        var t = this, e = "", a = "";
        console.log(this.data._root_tag), this.data.isOpenTeam ? (console.log("一键开团，leveid", this.data.isOpenTeam), 
        e = "plugin.fight-groups.frontend.controllers.team.pre-open-team", a = s.getNetAddresss(e), 
        a += "&level_id=" + this.options.level_id, a += "&option_level_id=" + this.options.option_level_id) : this.data.isJoinTeam ? (console.log("去参团", this.data.isJoinTeam), 
        e = "plugin.fight-groups.frontend.controllers.team.pre-join-team", a = s.getNetAddresss(e), 
        a += "&team_id=" + this.options.team_id, a += "&option_level_id=" + this.options.option_level_id) : "POrder" == this.data._root_tag ? (e = "plugin.pending-order.frontend.goods-buy.index", 
        a = s.getNetAddresss(e), a += "&pending_order_type=" + this.data.POChooseType) : "auction" == this.data._root_tag ? (a = s.getNetAddresss("plugin.auction.api.goods-buy"), 
        a += "&auction_sn=" + this.data.options.auction_sn, a += "&fixed_price=" + this.data.options.fixed_price) : (e = "order.goods-buy", 
        a = s.getNetAddresss(e)), a += "&goods_id=" + this.data._goodsId, a += "&total=" + this.data._total, 
        a += "&option_id=" + this.data._optionsId, a += "&member_coupon_ids=" + this._assembleCoupons(), 
        a += "&orders=" + JSON.stringify(this._assembleDeduction()), a += "&address=" + JSON.stringify(this.data.currentAddress), 
        a += "&dispatch_type_id=1", a += "&mark=" + (this.data.options.mark ? this.data.options.mark : 0), 
        s._getNetWork({
            url: a,
            success: function(e) {
                var a = e.data;
                1 == a.result ? (t.setData({
                    goodsInfo: a.data,
                    cup_notice: !0
                }), t._setViewData(a.data), t._setAddressViewData(a.data.dispatch.default_member_address), 
                t._initCoupon(a.data.discount.member_coupons), t.data.is_open_package_deliver && t.setData({
                    selfCarryType: a.data.dispatch.delivery_method
                })) : ("POrder" == t.data._root_tag && (t.setData({
                    cup_notice: !0
                }), wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                }), setTimeout(function() {
                    wx.navigateBack({
                        delta: 1
                    });
                }, 1e3)), "auction" == t.data._root_tag && wx.navigateBack({
                    delta: 1
                }), t.setData({
                    cup_notice: !0
                }), wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getExchangeData: function(t) {
        var e = this, a = s.getNetAddresss("coupon.exchange-center.exchange-buy");
        console.log("dkjsakjfaskf", JSON.parse(this.data.options.exchangeData)), s._postNetWork({
            url: a,
            showToastIn: !1,
            data: {
                goods_id: this.data._goodsId,
                total: this.data._total,
                option_id: this.data._optionsId,
                member_coupon_ids: this._assembleCoupons(),
                orders: JSON.stringify(this._assembleDeduction()),
                address: JSON.stringify(this.data.currentAddress),
                dispatch_type_id: 1,
                mark: this.data.options.mark ? this.data.options.mark : 0,
                data: JSON.parse(this.data.options.exchangeData),
                is_exchange: 0 == t ? 0 : 1
            },
            success: function(t) {
                var a = t.data;
                1 == a.result ? (e.setData({
                    goodsInfo: a.data,
                    cup_notice: !0
                }), e._setViewData(a.data), e._setAddressViewData(a.data.dispatch.default_member_address), 
                e._initCoupon(a.data.discount.member_coupons)) : (e.setData({
                    cup_notice: !0
                }), wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                }));
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    submit: function() {
        var t = this;
        if (1 == this.data.submit_active) {
            if (this.data.submit_active = !1, this.data.AgreementPay && !this.data.isRent && !this.data.agreementPay) return wx.showToast({
                icon: "none",
                title: "请勾选支付协议",
                duration: 1500
            }), void (this.data.submit_active = !0);
            if (this.data.is_open_package_deliver && 8 == this.data.package_deliver_id) {
                if (s._isTextEmpty(this.data.defaultSelfCarry.id)) return wx.showModal({
                    title: "提示",
                    content: "请选择自提点",
                    showCancel: !1,
                    confirmText: "确定",
                    confirmColor: "#000000",
                    success: function(t) {},
                    fail: function(t) {},
                    complete: function(t) {}
                }), void (this.data.submit_active = !0);
                if (s._isTextEmpty(this.data.linkinfo.name)) return wx.showModal({
                    title: "提示",
                    content: "请填写提货人姓名",
                    showCancel: !1,
                    confirmText: "确定",
                    confirmColor: "#000000",
                    success: function(t) {},
                    fail: function(t) {},
                    complete: function(t) {}
                }), void (this.data.submit_active = !0);
                if (s._isTextEmpty(this.data.linkinfo.mobile)) return wx.showModal({
                    title: "提示",
                    content: "请输入提货人手机",
                    showCancel: !1,
                    confirmText: "确定",
                    confirmColor: "#000000",
                    success: function(t) {},
                    fail: function(t) {},
                    complete: function(t) {}
                }), void (this.data.submit_active = !0);
            }
            if (this.data.isRent) {
                if (this.data.store_id) return this._submitStore(), void (this.data.submit_active = !0);
                if (!this.data.order_data[0].need_address && this.data.is_open_package_deliver && 8 != this.data.package_deliver_id && s._isTextEmpty(this.data.currentAddId)) return wx.showModal({
                    title: "提示",
                    content: "请选择收货地址",
                    showCancel: !1,
                    confirmText: "确定",
                    confirmColor: "#000000",
                    success: function(e) {
                        t.showAddress();
                    },
                    fail: function(t) {},
                    complete: function(t) {}
                }), void (this.data.submit_active = !0);
                if (!this.data.agreement) return wx.showToast({
                    icon: "none",
                    title: "请勾选租赁协议",
                    duration: 1500
                }), void (this.data.submit_active = !0);
                var e = this, a = "";
                "POrder" == this.data._root_tag ? (a = s.getNetAddresss("plugin.pending-order.frontend.create.index"), 
                a += "&pending_order_type=" + this.data.POChooseType) : "auction" == this.data._root_tag ? (a = s.getNetAddresss("plugin.auction.api.order-create"), 
                a += "&auction_sn=" + this.data.options.auction_sn) : a = s.getNetAddresss("plugin.lease-toy.api.order.create");
                var i = this._assembleJson();
                s._postNetWork({
                    url: a,
                    showToastIn: !1,
                    data: i,
                    success: function(t) {
                        var a = t.data;
                        1 == a.result ? (e._clearStorage(), e.data.submit_active = !0, wx.redirectTo({
                            url: "../orderPay/orderPay?order_id=" + a.data.order_ids + "&status=2"
                        })) : (wx.showToast({
                            icon: "none",
                            title: a.msg,
                            duration: 2e3
                        }), e.data.submit_active = !0);
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                });
            } else {
                if (this.data.store_id) return this._submitStore(), void (this.data.submit_active = !0);
                if (!this.data.order_data[0].need_address && !this.data.is_open_package_deliver && "8" != this.data.package_deliver_id && s._isTextEmpty(this.data.currentAddId)) return wx.showModal({
                    title: "提示",
                    content: "请选择收货地址",
                    showCancel: !1,
                    confirmText: "确定",
                    confirmColor: "#000000",
                    success: function(e) {
                        t.showAddress();
                    },
                    fail: function(t) {},
                    complete: function(t) {}
                }), void (this.data.submit_active = !0);
                var o, d = this, r = this._assembleJson();
                this.data.isOpenTeam || this.data.isJoinTeam ? o = s.getNetAddresss("plugin.fight-groups.frontend.controllers.create.index") : "POrder" == this.data._root_tag ? (o = s.getNetAddresss("plugin.pending-order.frontend.create.index"), 
                o += "&pending_order_type=" + this.data.POChooseType, console.log("进porder")) : "auction" == this.data._root_tag ? (o = s.getNetAddresss("plugin.auction.api.order-create"), 
                o += "&auction_sn=" + this.data.options.auction_sn) : o = s.getNetAddresss("order.create"), 
                s._postNetWork({
                    url: o,
                    showToastIn: !1,
                    data: r,
                    success: function(t) {
                        var e = t.data;
                        if (1 == e.result) {
                            if (d.data.submit_active = !0, d.options.option_level_id) return void wx.redirectTo({
                                url: "../orderPay/orderPay?order_id=" + e.data.order_ids + "&status=2&name=groups"
                            });
                            console.log("跳转到订单页"), wx.redirectTo({
                                url: "/packageD/buy/orderPay/orderPay?order_id=" + e.data.order_ids + "&status=2"
                            });
                        } else wx.showToast({
                            icon: "none",
                            title: e.msg,
                            duration: 1500
                        });
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                });
            }
        }
    },
    _submitStore: function() {
        var t = this;
        if (null == this.data.store_info.delivery_information || 0 == this.data.store_info.delivery_information) {
            if (("1" == this.data.selected || "3" == this.data.selected) && s._isTextEmpty(this.data.currentAddId) && !this.data.order_data[0].need_address && this.data.is_open_package_deliver && 8 != this.data.package_deliver_id) return wx.showModal({
                title: "提示",
                content: "请选择收货地址",
                showCancel: !1,
                confirmText: "确定",
                confirmColor: "#000000",
                success: function(e) {
                    t.showAddress();
                },
                fail: function(t) {},
                complete: function(t) {}
            }), void (this.data.submit_active = !0);
            var e = s.getNetAddresss("plugin.store-cashier.frontend.store.create"), a = {
                dispatch_type_id: this.data.selected,
                store_id: this.data.store_id,
                mobile: this.data.store_info.store_mobile,
                realname: this.data.store_info.store_name,
                address: JSON.stringify(this.data.currentAddress),
                goods: JSON.stringify(this._assembleGoods()),
                cart_ids: JSON.stringify(this.data.storeCarts),
                member_coupon_ids: JSON.stringify(this._assembleCoupons()),
                orders: JSON.stringify(this._assembleDeduction()),
                invoice_type: this.data.iscur_c ? 0 : 1,
                rise_type: this.data.iscur ? 1 : 0,
                call: this.data.invoice_list.call,
                company_number: this.data.invoice_list.company_number
            };
            s._postNetWork({
                url: e,
                showToastIn: !1,
                data: a,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? wx.redirectTo({
                        url: "../orderPay/orderPay?order_id=" + e.data.order_ids + "&status=2"
                    }) : wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else if (1 == this.data.store_info.delivery_information) {
            if ("2" == this.data.selected && (s._isTextEmpty(this.data.linkinfo.name) || s._isTextEmpty(this.data.linkinfo.mobile))) return wx.showToast({
                icon: "none",
                title: "请输入提货人信息",
                duration: 1500
            }), void (this.data.submit_active = !0);
            if (("1" == this.data.selected || "3" == this.data.selected) && s._isTextEmpty(this.data.currentAddId) && !this.order_data[0].need_address && this.data.is_open_package_deliver && 8 != this.data.package_deliver_id) return wx.showModal({
                title: "提示",
                content: "请选择收货地址",
                showCancel: !1,
                confirmText: "确定",
                confirmColor: "#000000",
                success: function(e) {
                    t.showAddress();
                },
                fail: function(t) {},
                complete: function(t) {}
            }), void (this.data.submit_active = !0);
            if ("2" == this.selected && !/^[0-9]{1,}$/.test(this.data.linkinfo.mobile)) return wx.showToast({
                icon: "none",
                title: "请输入正确的联系电话",
                duration: 1500
            }), void (this.data.submit_active = !0);
            var i = s.getNetAddresss("plugin.store-cashier.frontend.store.create"), o = this._assembleJson();
            s._postNetWork({
                url: i,
                showToastIn: !1,
                data: o,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? wx.redirectTo({
                        url: "../orderPay/orderPay?order_id=" + e.data.order_ids + "&status=2"
                    }) : wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    _assembleGoods: function() {
        for (var t = [], e = 0; e < this.data.goodsInfo.orders.length; e++) for (var a = 0; a < this.data.goodsInfo.orders[e].order_goods.length; a++) {
            var s = new Object();
            s.goods_id = this.data.goodsInfo.orders[e].order_goods[a].goods_id, s.total = this.data.goodsInfo.orders[e].order_goods[a].total, 
            s.option_id = this.data.goodsInfo.orders[e].order_goods[a].goods_option_id, t.push(s);
        }
        return t;
    },
    _assembleJson: function() {
        var t = {};
        if (this.data._root_tag == this.data.TAG_ACTION_BUY || "auction" == this.data._root_tag) t = {
            dispatch_type_id: 1,
            address: JSON.stringify(this.data.currentAddress),
            auction_sn: this.data.options.auction_sn,
            fixed_price: "1",
            goods: JSON.stringify(this._assembleGoods()),
            member_coupon_ids: JSON.stringify(this._assembleCoupons()),
            orders: JSON.stringify(this._assembleDeduction()),
            mark: this.data.options.mark ? this.data.options.mark : 0,
            invoice_type: this.data.iscur_c ? 0 : 1,
            rise_type: this.data.iscur ? 1 : 0,
            call: this.data.invoice_list.call,
            company_number: this.data.invoice_list.company_number
        }, this.data.isOpenTeam ? (t.level_id = this.options.level_id, t.option_level_id = this.options.option_level_id) : this.data.isJoinTeam && (t.team_id = this.options.team_id, 
        t.option_level_id = this.options.option_level_id); else if (this.data._root_tag == this.data.TAG_ACTION_CART) t = {
            dispatch_type_id: 1,
            address: JSON.stringify(this.data.currentAddress),
            goods: JSON.stringify(this._assembleGoods()),
            cart_ids: JSON.stringify(this.data._cart_ids),
            member_coupon_ids: JSON.stringify(this._assembleCoupons()),
            orders: JSON.stringify(this._assembleDeduction()),
            invoice_type: this.data.iscur_c ? 0 : 1,
            rise_type: this.data.iscur ? 1 : 0,
            call: this.data.invoice_list.call,
            company_number: this.data.invoice_list.company_number
        }; else if ("store" == this.data._root_tag) t = {
            dispatch_type_id: this.data.selected,
            store_id: this.data.store_id,
            mobile: this.data.linkinfo.mobile,
            realname: this.data.linkinfo.name,
            address: JSON.stringify(this.data.currentAddress),
            goods: JSON.stringify(this._assembleGoods()),
            cart_ids: JSON.stringify(this.data.storeCarts),
            member_coupon_ids: JSON.stringify(this._assembleCoupons()),
            orders: JSON.stringify(this._assembleDeduction()),
            invoice_type: this.data.iscur_c ? 0 : 1,
            rise_type: this.data.iscur ? 1 : 0,
            call: this.data.invoice_list.call,
            company_number: this.data.invoice_list.company_number
        }; else if ("rentCartBuy" == this.data._root_tag || "rentBuy" == this.data._root_tag) {
            var e = "";
            try {
                var a = wx.getStorageSync("rentTimeRight");
                a && (e = a);
            } catch (t) {}
            var i = "";
            try {
                var o = wx.getStorageSync("rentTimeChoose");
                o && (i = o);
            } catch (t) {}
            var d = "";
            try {
                var r = wx.getStorageSync("rentTimeSelf");
                r && (d = r);
            } catch (t) {}
            t = {
                lease_rights: null == s._isTextEmpty(e) ? [] : e,
                lease_term: s._isTextEmpty(i) ? s._isTextEmpty(d) ? {} : d : i,
                dispatch_type_id: 1,
                address: JSON.stringify(this.data.currentAddress),
                goods: JSON.stringify(this._assembleGoods()),
                cart_ids: JSON.stringify(this.data._cart_ids),
                member_coupon_ids: JSON.stringify(this._assembleCoupons()),
                orders: JSON.stringify(this._assembleDeduction()),
                mark: this.data.options.mark ? this.data.options.mark : 0,
                invoice_type: this.data.iscur_c ? 0 : 1,
                rise_type: this.data.iscur ? 1 : 0,
                call: this.data.invoice_list.call,
                company_number: this.data.invoice_list.company_number
            };
        } else ("POrder" == this.data._root_tag || "fromExchange" == this.data._root_tag) && (t = {
            dispatch_type_id: 1,
            address: JSON.stringify(this.data.currentAddress),
            goods: JSON.stringify(this._assembleGoods()),
            member_coupon_ids: JSON.stringify(this._assembleCoupons()),
            orders: JSON.stringify(this._assembleDeduction()),
            mark: this.data.options.mark ? this.data.options.mark : 0,
            invoice_type: this.data.iscur_c ? 0 : 1,
            rise_type: this.data.iscur ? 1 : 0,
            call: this.data.invoice_list.call,
            company_number: this.data.invoice_list.company_number
        });
        return this.data.is_open_package_deliver && 8 == this.data.package_deliver_id && (t.dispatch_type_id = 8, 
        t.package_deliver_id = this.data.defaultSelfCarry.id, t.realname = this.data.linkinfo.name, 
        t.mobile = this.data.linkinfo.mobile, delete t.address), t;
    },
    setDispatchdeliver: function(t) {
        console.log("变化配送方式", t.detail.title);
        var e = t.detail.title;
        "快递" == e ? this.setData({
            package_deliver_id: 1,
            selfCarrySelected: 0
        }) : "上门自提" == e && this.setData({
            package_deliver_id: 8,
            selfCarrySelected: 1
        });
    },
    getAgreementPay: function() {
        var t = this, e = s.getNetAddresss("shop.index.getPayProtocol");
        s._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                1 == a.result && t.setData({
                    AgreementPay: a.data ? a.data : ""
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    agreementPaybtn: function(t) {
        var e = t.detail;
        this.setData({
            agreementPay: e
        });
    },
    showPay: function() {
        this.setData({
            agreementPayShow: !0
        });
    },
    showPayClose: function() {
        this.setData({
            agreementPayShow: !1
        });
    },
    getIvoice: function(t) {
        this.setData({
            papery_status: parseInt(t.invoice.papery),
            electron_status: parseInt(t.invoice.electron)
        }), this.data.papery_status || this.data.electron_status || this.setData({
            isShowInvoice: !1
        });
    },
    getCashGood: function() {
        var t = s.getNetAddresss("plugin.store-cashier.frontend.store.enter.getSetGoodsId"), e = this;
        s._getNetWork({
            url: t,
            data: {},
            success: function(t) {
                var a = t.data;
                1 == a.result ? (e.setData({
                    goods_id: a.data.goods_id
                }), a.data.store ? (e.setData({
                    _root_tag: "store"
                }), e.setData({
                    store_info: a.data.store,
                    dispatch: a.data.store.dispatch_type
                }), e.data.dispatch.length > 0 && (e.data.selected || e.setData({
                    selected: e.data.dispatch[0].toString()
                })), e._getDataActionStoreCart()) : (e.setData({
                    _goodsId: a.data.goods_id,
                    _root_tag: "-2",
                    store_id: 0
                }), e._getDataActionBuy())) : wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getParams: function(t) {
        var e, a = this;
        if ("store" != this.data._root_tag || t) {
            if ("store" == this.data._root_tag && t && this.setData({
                _cart_ids: t
            }), this.data._root_tag == this.data.TAG_ACTION_BUY || "auction" == this.data._root_tag) {
                this.setData({
                    _goodsId: this.data.options.goodsId
                });
                var i = this.data._cart_ids;
                i.push(this.data._goodsId), this.setData({
                    _cart_ids: i
                });
            } else if (this.data._root_tag == this.data.TAG_ACTION_CART) this.setData({
                _cart_ids: this.data.options.cart_ids ? JSON.parse(this.data.options.cart_ids) : []
            }); else if ("rentCartBuy" == this.data._root_tag) this.setData({
                _cart_ids: this.data.options.cart_ids ? JSON.parse(this.data.options.cart_ids) : []
            }); else if ("rentBuy" == this.data._root_tag) {
                this.setData({
                    _goodsId: this.data.options.goodsId
                });
                var o = this.data._cart_ids;
                o.push(this.data._goodsId), this.setData({
                    _cart_ids: o
                });
            }
            var d = s.getNetAddresss("from.div-from.get-params");
            e = {
                goods_ids: JSON.stringify(this.data._cart_ids)
            }, s._getNetWork({
                url: d,
                data: e,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? (a.setData({
                        isGetAgreementPay: !0,
                        AgreementPay: e.data.getPayProtocol ? e.data.getPayProtocol : ""
                    }), a._checkTaxGoods(e.data.isDisplay), a._getMemberInfo(e.data.getMemberInfo), 
                    a._getExplain(e.data.explain), a.getIvoice(e.data.sinvoice)) : a.setData({
                        isGetAgreementPay: !1
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    show1btn: function() {
        this.setData({
            show1: !0
        });
    },
    closePopup: function() {
        this.setData({
            show1: !1
        });
    },
    invoice_type: function() {
        this.data.iscur_c ? this.setData({
            iscur_c: !1,
            iscur_d: !0
        }) : this.setData({
            iscur_c: !0,
            iscur_d: !1
        });
    },
    invoice_title: function() {
        this.setData({
            "invoice_list.call": "",
            "invoice_list.company_number": ""
        }), this.data.iscur ? this.setData({
            iscur: !1,
            iscur_b: !0,
            person_status: !1,
            unit_status: !0
        }) : this.setData({
            iscur: !0,
            iscur_b: !1,
            person_status: !0,
            unit_status: !1
        });
    },
    Subinvoice: function() {
        s._isTextEmpty(this.data.invoice_list.call) ? wx.showToast({
            title: "请填写抬头",
            icon: "none",
            duration: 1500
        }) : this.data.iscur_b && s._isTextEmpty(this.data.invoice_list.company_number) ? wx.showToast({
            title: "请添加纳税人识别号",
            icon: "none",
            duration: 1500
        }) : this.setData({
            invoicename: this.data.iscur_c ? "电子" : "纸质",
            companyname: this.data.iscur ? "个人" : "单位",
            showInvoiceTitle: this.data.invoice_list.call,
            show1: !1
        });
    },
    callinp: function(t) {
        var e = t.detail.value;
        this.setData({
            "invoice_list.call": e
        });
    },
    companyNumberinp: function(t) {
        var e = t.detail.value;
        this.setData({
            "invoice_list.company_number": e
        });
    },
    getList: function() {
        var t = this, e = s.getNetAddresss("plugin.package-deliver.frontend.deliver.getList");
        s._getNetWork({
            url: e,
            data: {
                city_name: t.data.city,
                lat: t.data.point.lat,
                lng: t.data.point.lng,
                kwd: ""
            },
            success: function(e) {
                var a = e.data;
                1 == a.result ? t.setData({
                    defaultSelfCarry: a.data.list.data[0] ? a.data.list.data[0] : "",
                    package_deliver_id: a.data.list.data[0].dispatch_type_id
                }) : wx.showToast({
                    icon: "none",
                    title: "获取自提点失败",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});